package com.lzk.basic.util;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class JsonResult {
    private  Boolean success = true;
    private  String msg = "操作成功";
    //用于返回前端数据
    private  Object resultObj ;


    private static JsonResult allJsonResult = new JsonResult();
    private static JsonResult noJsonResult = new JsonResult(false,"操作失败");
    //单例模式
    public static JsonResult me(Boolean success,String msg){
        if(success != null && msg != null){
            return noJsonResult;
        }
        return allJsonResult;
    }
    public static JsonResult me() {
        return allJsonResult;
    }

    public static JsonResult me(String msg){
        return new JsonResult(false,msg);
    }


    public JsonResult(Boolean success, String msg) {
        this.success = success;
        this.msg = msg;
    }
    public JsonResult setResultObj(Object resultObj){
        this.resultObj=resultObj;
        return this;
    }
}
